Skip to content

feat(v2): manage session families across worktrees - #649

Open
pascalandr wants to merge 17 commits into
NeuralNomadsAI:DEV-v2from
pascalandr:v2/worktree-sessions
Open

feat(v2): manage session families across worktrees#649
pascalandr wants to merge 17 commits into
NeuralNomadsAI:DEV-v2from
pascalandr:v2/worktree-sessions

Conversation

@pascalandr

@pascalandr pascalandr commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • use native OpenCode V2 project/session APIs to inventory, move, verify, and roll back complete session families across Git worktrees
  • make worktree deletion transactional by evacuating inactive families and blocking physical roots used by published or starting workspaces
  • organize the session list by authoritative SessionInfo.location with worktree badges, sorting, filtering, and localized root labels
  • add authorized Electron and Tauri actions to open verified local worktree directories in the system file manager

This supersedes #642 with a native V2 implementation. #642 is intentionally left open and unchanged.

Updated V2 Contract

Merged DEV-v2@e1987b9c; PR HEAD is faaa2b39 (1,317+/350-, 49 files).

  • complete project inventories use native cursor pagination without directory filters; descendant families are not constrained to a parent's worktree subpath
  • session moves remain serialized and transactional across complete families with active-session blocking, asynchronous completion verification, Git identity revalidation, and rollback after move or Git deletion failure
  • direct worktree deletion fails closed and cannot bypass server-side evacuation
  • global Forms retain logical workspace location, native cursor scopes are proxy-validated, and reconnect reload failures remain retryable
  • server/UI generated client dependencies remain pinned to 0.0.0-beta-17595; the independently updated CLI is validated through service/API compatibility without an exact version gate

Safety

  • bounded cursor traversal with malformed, duplicate, and repeated-cursor rejection
  • per-project transaction serialization, active-session blocking, authoritative verification, and rollback
  • strict NUL-delimited Git inventory parsing with prunable/duplicate rejection and HEAD/path revalidation
  • physical worktree deletion reservations block nested published and in-flight logical workspaces
  • desktop commands authorize current renderer requests against current workspace/worktree membership, canonicalize targets, and enforce containment before opening supported files or directories

Validation

  • server and UI typechecks
  • focused gate regressions: server 18/18; inherited UI composition 11/11
  • inherited base matrix: UI 199/199 + 47/47, Electron 122/122, server 255 passed with 3 platform skips
  • server/UI/Electron production builds, standalone server lockfile install, Tauri cargo check --locked, and git diff --check

Residual Limit

OpenCode V2 and Git do not expose snapshot/CAS transactions for external clients. CodeNomad fails closed and narrows races with reservations and repeated authoritative checks, but an independent process can still mutate sessions, worktrees, or paths after the final check.

Use the shared OpenCode V2 service to inventory complete project session families and move them through the native session.move API. Serialize project operations, verify authoritative locations, and roll back only transaction-owned moves when failures occur.

Make worktree deletion transactional by evacuating inactive session families before Git removal. Strict NUL-delimited inventory checks, HEAD revalidation, physical-root workspace reservations, nested workspace projection, and cache invalidation prevent stale or in-use worktrees from being removed.

Cover cursor pagination, family resolution, rollback, deletion evacuation, nested logical roots, exact Git slug resolution, and workspace creation races. Validated with server typecheck and the full 237-test server suite.
Treat SessionInfo.location as the authoritative worktree assignment, load every project-scoped cursor page, and project complete session families for search, filtering, and activity/name/worktree sorting. Family moves now run through the server transaction and refresh from OpenCode instead of mutating local paths optimistically.

Show localized root and linked-worktree badges, preserve complete ancestry during filters, refresh worktrees and sessions after deletion, and apply the complete authoritative session.moved payload. Expose the desktop file-manager action only for local paths with keyboard support.

Add coverage for project query construction, path normalization, family projection, native move events, request authority, serialized family moves, and deletion refresh; register the new runnable tests in CI. Validated with UI typecheck, 35 affected CI-mode tests, and production builds.
Add desktop-only Electron and Tauri commands for revealing local worktree directories. Reuse the existing renderer token, origin, frame, and generation authority instead of introducing a separate bridge.

Reject relative, control, network, device, and non-directory targets before opening. Canonicalize inputs, require exact NUL-delimited Git inventory membership, constrain logical subdirectories beneath registered worktrees, and repeat authorization and inventory checks to narrow races.

Keep Electron and Tauri behavior aligned with targeted parser, validation, authorization, containment, and revalidation tests. Validated with Electron typecheck and 124/124 native tests plus cargo check and 87/87 Rust tests.
@pascalandr
pascalandr marked this pull request as ready for review August 17, 2026 08:27
Integrate the current native V2 routing, workspace controls, shared desktop opener, lifecycle hardening, and pruned validation matrix while removing the PR's duplicate Electron and Tauri file-manager bridges.

Inventory sessions through paginated native project filtering, move complete families transactionally, revalidate worktree path and HEAD immediately before deletion, and fail closed if a checkout is replaced. Preserve evacuated sessions at the safe root rather than rolling them into a replacement checkout.

Reduce feature tests to project pagination, family moves, rollback, active-session blocking, replacement races, route ownership, UI projection, and authoritative refresh. Server, UI, Electron, and Rust checks plus focused suites and diff checks pass; the full server matrix had one transient process timeout that passed alone.
Merge upstream DEV-v2 while retaining server-owned transactional worktree evacuation. The UI issues one deletion request and refreshes authoritative worktree and session state, avoiding partial client-cache-driven family moves; server deletion remains blocked whenever complete-family evacuation fails and rolls back transaction-owned moves.

Preserve the upstream native createData and cursor pagination contracts and the removal of forceNew canonical duplication. Validated with server and UI typechecks, focused server worktree transaction tests, focused UI browser integration and pagination tests, and git diff checks.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32199550180

Artifacts expire in 7 days.
Artifacts:

  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-macos-arm64
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-windows
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-macos
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-macos
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-linux
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-linux
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-windows

1 similar comment
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32199550180

Artifacts expire in 7 days.
Artifacts:

  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-macos-arm64
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-windows
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-macos
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-macos
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-linux
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-linux
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-windows

…60818

# Conflicts:
#	packages/server/src/server/routes/worktrees.test.ts
#	packages/server/src/server/routes/worktrees.ts
…60818

# Conflicts:
#	packages/server/src/server/routes/worktrees.ts
#	packages/server/src/workspaces/worktree-session-evacuation.test.ts
#	packages/server/src/workspaces/worktree-session-evacuation.ts
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32202206795

Artifacts expire in 7 days.
Artifacts:

  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-macos
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-macos-arm64
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-windows
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-macos
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-linux
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-linux
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-windows

1 similar comment
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32202206795

Artifacts expire in 7 days.
Artifacts:

  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-macos
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-macos-arm64
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-windows
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-macos
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-linux
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-linux
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-windows

# Conflicts:
#	packages/server/src/workspaces/worktree-session-evacuation.ts
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32215068777

Artifacts expire in 7 days.
Artifacts:

  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-macos
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-macos
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-macos-arm64
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-linux
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-linux
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-windows
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-windows

1 similar comment
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32215068777

Artifacts expire in 7 days.
Artifacts:

  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-macos
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-macos
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-macos-arm64
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-linux
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-linux
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-windows
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-windows

Translate host worktree paths into the OpenCode service namespace before project resolution, moves, and evacuation while retaining host paths for Git deletion and reservations. Publish serviceDirectory so WSL session grouping and filtering compare native locations correctly.

Reject malformed cursors, poll boundedly for move and rollback visibility, and recheck activity before each move and Git removal. Add malformed-cursor, delayed-visibility, concurrent-activation, and route regressions; validate server/UI/Electron typechecks, 18 focused tests, and diff cleanliness.
Resolve OpenCode targets from mirrored nested workspace paths while preserving physical roots for Git operations. Determine rollback ownership from per-session state and compare POSIX service paths with case-sensitive semantics on Windows hosts.

Add nested-route, stale-inventory rollback, and WSL case-sensitivity regressions; validate server typecheck, 20 focused tests, and diff cleanliness.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32226249423

Artifacts expire in 7 days.
Artifacts:

  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-tauri-linux
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-tauri-macos-arm64
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-tauri-macos
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-tauri-windows
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-electron-macos
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-electron-linux
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-electron-windows

Migrate the Status panel from interactive PTYs to the location-scoped shell API, refresh shell state after lifecycle events and reconnects, and route locationless shell events by their owned working directory.

Allowlist shell routes explicitly and verify ShellInfo.cwd before every ID-scoped request, including trailing-slash aliases, while preserving native output cursor parameters. Keep PTYs separate for interactive terminal use.

Load project metadata before the first session inventory, preserve native projected message order, invalidate inactive transcripts instead of reloading every transcript after reconnect, and keep native shutdown terminal without latching ordinary navigation flushes.

Update V2 documentation and CI test paths. Validated with UI and server typechecks, 15 focused UI tests, 35 focused server tests, and git diff --check.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32262724562

Artifacts expire in 7 days.
Artifacts:

  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-tauri-macos
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-electron-macos
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-tauri-windows
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-tauri-macos-arm64
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-tauri-linux
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-electron-linux
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-electron-windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant